﻿using AuSys.Repos.Files;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace AuSys.Controllers.Files
{
    [Authorize]
    [ApiController]
    [Route(ApiConsts.routePattern)]
    public class FileItemController(
        FileItemRepo fileItemRepo)
    {
        [HttpPost]
        public int TryCreateFileItem(IFormFile file)
        {
            using var stream = file.OpenReadStream();
            return fileItemRepo.TryCreateFileItem(stream, file.FileName);
        }
    }
}
